/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Frmfactura_item.java
 *
 * Created on 29/05/2011, 13:53:13
 */

package logano;

import loganosystem.contrato.Factura_item;
import util.Helper;

/**
 *
 * @author loreh
 */
public class Frmfactura_item extends FrmBaseEdicion {

    Factura_item facturai = new Factura_item();
    /** Creates new form Frmfactura_item */
    public Frmfactura_item() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtprecio_unitario = new javax.swing.JLabel();
        txtcantidad = new javax.swing.JLabel();
        btaceptar = new javax.swing.JButton();
        btlimpiar = new javax.swing.JButton();
        btcancelar = new javax.swing.JButton();
        tbprecio_unit = new javax.swing.JTextField();
        tbcantidad = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(logano.LoganoApp.class).getContext().getResourceMap(Frmfactura_item.class);
        txtprecio_unitario.setText(resourceMap.getString("txtprecio_unitario.text")); // NOI18N
        txtprecio_unitario.setName("txtprecio_unitario"); // NOI18N

        txtcantidad.setText(resourceMap.getString("txtcantidad.text")); // NOI18N
        txtcantidad.setName("txtcantidad"); // NOI18N

        btaceptar.setText(resourceMap.getString("btaceptar.text")); // NOI18N
        btaceptar.setName("btaceptar"); // NOI18N
        btaceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btaceptarActionPerformed(evt);
            }
        });

        btlimpiar.setText(resourceMap.getString("btlimpiar.text")); // NOI18N
        btlimpiar.setName("btlimpiar"); // NOI18N
        btlimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btlimpiarActionPerformed(evt);
            }
        });

        btcancelar.setText(resourceMap.getString("btcancelar.text")); // NOI18N
        btcancelar.setName("btcancelar"); // NOI18N
        btcancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btcancelarActionPerformed(evt);
            }
        });

        tbprecio_unit.setText(resourceMap.getString("tbprecio_unit.text")); // NOI18N
        tbprecio_unit.setName("tbprecio_unit"); // NOI18N
        tbprecio_unit.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbprecio_unitKeyPressed(evt);
            }
        });

        tbcantidad.setText(resourceMap.getString("tbcantidad.text")); // NOI18N
        tbcantidad.setName("tbcantidad"); // NOI18N
        tbcantidad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tbcantidadKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtprecio_unitario)
                            .addComponent(txtcantidad))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(tbcantidad)
                            .addComponent(tbprecio_unit, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(btaceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btlimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btcancelar)))
                .addContainerGap(98, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(69, 69, 69)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbprecio_unit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtprecio_unitario))
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tbcantidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtcantidad))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btaceptar)
                    .addComponent(btlimpiar)
                    .addComponent(btcancelar))
                .addGap(50, 50, 50))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btaceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btaceptarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btaceptarActionPerformed

    private void btlimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btlimpiarActionPerformed
        txtcantidad.setText("");
        txtprecio_unitario.setText("");
    }//GEN-LAST:event_btlimpiarActionPerformed

    @Override
    protected Factura_item getValues()
    {
       this.facturai.setPrecio_unitario(tbprecio_unit.getText());
       this.facturai.setCantidad(Integer.parseInt(tbcantidad.getText()));
       return this.facturai;
    }

    @Override
    protected void setValues()
    {

        this.tbcantidad.setText(String.valueOf(this.facturai.getCantidad()));
        this.tbprecio_unit.setText(String.valueOf(this.facturai.getPrecio_unitario()));

    }


    private void btcancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btcancelarActionPerformed

        dispose();
    }//GEN-LAST:event_btcancelarActionPerformed

    private void tbprecio_unitKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbprecio_unitKeyPressed
      Helper.enterKeyPressed(evt, tbcantidad);
    }//GEN-LAST:event_tbprecio_unitKeyPressed

    private void tbcantidadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tbcantidadKeyPressed
         Helper.enterKeyPressed(evt, tbprecio_unit);
    }//GEN-LAST:event_tbcantidadKeyPressed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Frmfactura_item().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btaceptar;
    private javax.swing.JButton btcancelar;
    private javax.swing.JButton btlimpiar;
    private javax.swing.JTextField tbcantidad;
    private javax.swing.JTextField tbprecio_unit;
    private javax.swing.JLabel txtcantidad;
    private javax.swing.JLabel txtprecio_unitario;
    // End of variables declaration//GEN-END:variables

}
